package com.heima.aliyun;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
/*
pom.xml
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>aliyun-java-sdk-core</artifactId>
  <version>4.6.0</version>
</dependency>
*/

public class ScanImage {
    public static void main(String[] args) {

        DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAI5tR3EmHGjr9q5oyD9gLg", "2iwCINZoqeoHNdhawj81XMbbrgb9jh");
        /** use STS Token
        DefaultProfile profile = DefaultProfile.getProfile(
            "<your-region-id>",           // The region ID
            "<your-access-key-id>",       // The AccessKey ID of the RAM account
            "<your-access-key-secret>",   // The AccessKey Secret of the RAM account
            "<your-sts-token>");          // STS Token
        **/

        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();

        request.setSysMethod(MethodType.POST);
        request.setSysDomain("imageaudit.cn-shanghai.aliyuncs.com");
        request.setSysVersion("2019-12-30");
        request.setSysAction("ScanImage");
        request.putQueryParameter("Task.1.ImageURL", "http://a6u9em.natappfree.cc/leadnews/2023/01/11/4efa2c474c46498c92bdc6cce81e8949.png");
        request.putQueryParameter("Task.2.ImageURL", "http://a6u9em.natappfree" +
                ".cc/leadnews/2023/01/11/4efa2c474c46498c92bdc6cce81e8949.png");
        request.putQueryParameter("Scene.1", "porn");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}